package tk.mybatis.web.controller;

import java.util.*;

import com.sun.deploy.net.HttpResponse;
import org.springframework.core.NamedThreadLocal;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMessage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class IndexController {
    @RequestMapping(value = {"", "/index"}, method = RequestMethod.GET)
    public ModelAndView dicts(HttpServletRequest request, HttpServletResponse response) {
        HttpServletRequest request2 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();

        StringBuffer url = request.getRequestURL();
        String uri = request.getRequestURI();
        String queryString = request.getQueryString();
        String remoteAddr = request.getRemoteAddr();
        String localAddr = request.getLocalAddr();
        String method = request.getMethod();
        String scheme = request.getScheme();
        String serverName = request.getServerName();
        int serverPort = request.getServerPort();
        String contextPath = request.getContextPath();
        String servletPath = request.getServletPath();
        String pathInfo = request.getPathInfo();
        String protocol = request.getProtocol();
        String parameter = request.getParameter("id");
        String[] parameterValues = request.getParameterValues("id");
        Enumeration parameterNames = request.getParameterNames();
        Map parameterMap = request.getParameterMap  ();
        ModelAndView mv = new ModelAndView("index");//redirect:path  forward:path
        mv.addObject("now", new Date());
        return mv;
    }

    @RequestMapping("web-socket-test")
    public ModelAndView webSocketTest() {
        return new ModelAndView("web-socket-test");
    }

    @RequestMapping("spring-web-socket-test")
    public ModelAndView springWebSocketTest() {
        return new ModelAndView("spring-web-socket-test");
    }

    @RequestMapping("web-socket-send")
    public ModelAndView webSocketSend() {
        return new ModelAndView("web-socket-send");
    }
}
